home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CColorBitMap / CColorBitMap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  2.8 KB  |  114 lines  |  [TEXT/KAHL]

  1. /***************************************
  2.  "CColorBitMap.h"
  3.  
  4.  by John A. Love, III [Ph.D. student]
  5.  
  6.  using Symantec's "THINK C / C++", v 6/7
  7.  based on Symantec's "TinyEdit"
  8.  ***************************************/
  9.  
  10.  
  11.  
  12.  
  13. #pragma    once                            /* Include this file only once          */
  14.  
  15.  
  16. #include <CBitMap.h>                    /* Include superclass                  */
  17.  
  18.  
  19. #define kMaxRowBytes    0x3FFE            /* Max # of bytes in a row of pixels. */
  20. #define kDefaultRes        0x00480000        /* Default resolution is 72 DPI;      */
  21.                                         /*   Fixed type.                      */
  22. #define kITabRes        4                /* Inverse-table resolution.          */
  23.  
  24.  
  25. /* ... for Error handling in my off-screen map routine(s): */
  26. enum
  27. {
  28.     NewPortError        = -10000,
  29.     DepthError            = -12000,
  30.     MaxRowBytesError    = -14000,
  31.     NewBaseAddrPtrError    = -16000,
  32.     ColorTableError        = -18000,
  33.     CreateGDeviceError    = -20000,
  34.     NilGDeviceError        = -22000,
  35.     ZoomWindowError        = -24000
  36. };
  37.  
  38.  
  39. class CColorBitMap : public CBitMap
  40. {
  41. public:
  42.  
  43.     /** Additional Instance Variables: **/
  44.     
  45.              /* GrafPtr            savePort;                --  in superclass */
  46.                 GDHandle        saveDevice;
  47.                 
  48.              /* BitMap            saveBitMap;                --  in superclass */
  49.                 PixMapHandle    savePixMap;
  50.  
  51.              /* GrafPtr            macPort;                --  in superclass */
  52.                 PixMapHandle    itsPixMap;
  53.                 Handle            macBits;
  54.                 CTabHandle        itsColors;
  55.                 GDHandle        itsMaxDevice;
  56.     
  57.  
  58.     /**
  59.         Additional or Overridden Instance Methods.
  60.         There are two major reasons.  The first
  61.         is to accomodate PixMaps in Color QuickDraw.
  62.         The other is to NOT have to HLock the
  63.         CColorBitMap's "itsPixMap" which necessitates
  64.         avoiding all references to "macBitMap"
  65.     **/
  66.  
  67.     
  68.                                 /* Contruction/Destruction                         */
  69.                                 /*                                                 */
  70.                                 /* Note that this method is NOT called "IBitMap" */
  71.                                 /* because that name is taken by CBitMap's         */
  72.                                 /* constructor method and constructors canNOT be */
  73.                                 /* virtual or overidden.                         */
  74.             void            IColorBitMap (short width, short height,
  75.                                           Boolean makePort);
  76.     virtual void            Dispose (void);
  77.     
  78.                                 /* good ole "Switch-A-Roo" */
  79.             void            Update (void);
  80.             
  81.     virtual Boolean            PixelIsBlack (LongPt *pixelPos);
  82.     
  83.                                 /* Preparing */
  84.     virtual void            BeginDrawing (void);
  85.     virtual void            EndDrawing (void);
  86.     
  87.                                 /* Drawing */
  88.     virtual void            CopyFrom (LongRect *fromRect, LongRect *toRect,
  89.                                       RgnHandle maskRgn);
  90.     virtual void            CopyTo (LongRect *fromRect, LongRect *toRect,
  91.                                     RgnHandle maskRgn);
  92.     
  93.                                 /* Offseting */
  94.     virtual void            GetBounds (LongRect *theBounds);
  95.     virtual void            SetBoundsOrigin (short hOrigin, short vOrigin);
  96.     
  97.                                 /** end of public methods **/
  98.  
  99. private:
  100.  
  101.                                 /* Miscellaneous */
  102.             CTabHandle        SetupPixMap (PixMapHandle aPixMap, Handle imageBits,
  103.                                          short bytesPerRow, Rect *theBounds);
  104.             GDHandle        CreateGDevice (PixMapHandle basePixMap);
  105.     
  106.                                 /** end of private methods **/
  107.  
  108. };    /* CColorBitMap */
  109.  
  110.  
  111.  
  112.  
  113. /* end: "CColorBitMap.h" */
  114.